package pers.hl.lib_global.model.bean

import android.os.Parcel
import android.os.Parcelable

/**
 * {
"libId": 1,
"libName": "图书馆一号",
"libLocation": "天府软件园D6",
"libLongitude": 104.06792346,
"libLatitude": 30.67994285
}
 */
data class Library(
    var libId: Int = -1,
    var libLatitude: Double,
    var libLongitude: Double,
    var libLocation: String?,
    var libName: String?,
    var distance: Int = 0
) : Parcelable {
    constructor(source: Parcel) : this(
        source.readInt(),
        source.readDouble(),
        source.readDouble(),
        source.readString(),
        source.readString(),
        source.readInt()
    )

    override fun describeContents() = 0

    override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
        writeInt(libId)
        writeDouble(libLatitude)
        writeDouble(libLongitude)
        writeString(libLocation)
        writeString(libName)
        writeInt(distance)
    }

    companion object {
        @JvmField
        val CREATOR: Parcelable.Creator<Library> = object : Parcelable.Creator<Library> {
            override fun createFromParcel(source: Parcel): Library = Library(source)
            override fun newArray(size: Int): Array<Library?> = arrayOfNulls(size)
        }
    }
}